<?php
/**
 * Created by PhpStorm.
 * User: zhao
 * Date: 2018/3/30
 * Time: 11:26
 */

namespace App\Observers;


use App\Models\WxuserStar;

class WxuserStarsOberserver
{
    /**
     * 监听星星记录创建事件.
     *
     * @param  WxuserWxcard  $wxuserWxcard
     * @return void
     */
    public function created(WxuserStar $wxuserStar)
    {
        if($wxuserStar->num>0){
            $wxuserStar->wxuser()->increment('remain_stars',$wxuserStar->num);
            $wxuserStar->wxuser()->increment('total_stars',$wxuserStar->num);
        }else{
            $wxuserStar->wxuser()->decrement('remain_stars',12);
        }

    }
}